<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>微博页面</h1>
<div id="v_div">
    <div v-if="user==''">
        <a href="/login.html">登入</a>
        <a href="/reg.html">注册</a>
    </div>
    <div v-if="user!=''">
        <a href="/send.html">发微博</a>
        <a href="#" @click="logout()">退出</a>
    </div>
</div>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el: "#v_div",
        data: {
            user: ""
        },
        created: function () {
            axios.get("/checkLogin").then(function (response) {
                v.user = response.data
            })
        },
        methods: {
            logout: function () {
                axios.get("/logout").then(function () {
                    location.reload();
                })
            }
        }

    })
</script>
</body>
</html>